#ifndef QT_ROS_NODE_H
#define QT_ROS_NODE_H

#include <QObject>
#include <QString>
#include <QTimer> //引入QTimer
#include "rclcpp/rclcpp.hpp" // IWYU pragma: keep
#include "std_msgs/msg/string.hpp"

class QtROSNode : public QObject, public rclcpp::Node
{
    Q_OBJECT
public:
    explicit QtROSNode(const std::string &node_name, QObject *parent = nullptr);
    ~QtROSNode();

public slots:
    void publishMessage(const QString &msg);
    void startTimer(); // 增加一个新的公共槽

private slots: // 增加一个私有槽
    void spin_some();

signals:
    void messageReceived(const QString &msg);

private:
    void topic_callback(const std_msgs::msg::String::SharedPtr msg);

    rclcpp::Publisher<std_msgs::msg::String>::SharedPtr publisher_;
    rclcpp::Subscription<std_msgs::msg::String>::SharedPtr subscription_;
    QTimer* m_ros_timer; // 添加QTimer成员
};

#endif // QT_ROS_NODE_H
